-
Notifications
You must be signed in to change notification settings - Fork 87
lf-queue: Rewrite based on Nikolaev's paper and hazard pointers #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lf-queue/atomics.h
Outdated
#define ATOMIC_RELEASE atomic_flag_clear | ||
|
||
#define ATOMIC_SUB atomic_fetch_sub | ||
#define ATOMIC_SUB64 ATOMIC_SUB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATOMIC_SUB64
is not really used. Drop it.
lf-queue/lfq.c
Outdated
struct lfq_node *p = ctx->fph; | ||
if ((!atomic_load(&p->can_free)) || (!atomic_load(&p->free_next)) || | ||
in_hp(ctx, (struct lfq_node *) p)) | ||
goto final; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using goto
, can you simply use break
statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
lf-queue/README.md
Outdated
@@ -1,8 +1,5 @@ | |||
# Multithreaded Bounded Lock-free Queue | |||
# lfq | |||
The lock-free queue implemented is based on the paper [A Scalable, Portable, and Memory-Efficient Lock-Free FIFO Queue](https://drops.dagstuhl.de/opus/volltexte/2019/11335/pdf/LIPIcs-DISC-2019-28.pdf) by Ruslan Nikolaev. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace "implemented" with "implementation."
Instead of using the old implementation, a concurrent queue based on Nikolaev's paper and hazard pointers is provided. The program has been rewritten using C11 Atomics to support other processor architectures, and it has solved the data race issues, enabling it to pass the runtime detection of Thread Sanitizer.
Thank @csm1735 for contributing! |
Instead of using the old implementation, a concurrent queue 'lfq' is provided, which can utilize hazard pointers to release memory.
The program has been rewritten using C11 Atomics to support other processor architectures, and it has solved the data race issues, enabling it to pass the runtime detection of Thread Sanitizer.